﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceManager.DataAccessLayer
{
    public class TinhTrangDbOperation:IDatabaseOperation<TINHTRANG>
    {
        QLThietBiEntities devicemanager;
        #region IDatabaseOperation<T> Members

        public int SaveRecord(TINHTRANG record)
        {
            try
            {
                using (devicemanager = new QLThietBiEntities())
                {
                    devicemanager.TINHTRANGs.Add(record);
                    devicemanager.SaveChanges();
                }
                return (int)record.TinhTrangID;
            }
            catch
            {
                return -1;
            }
        }
        #endregion

        public bool UpdateRecord(TINHTRANG record)
        {
            return false;
        }

        public List<TINHTRANG> GetRecord(TINHTRANG record)
        {
            devicemanager = new QLThietBiEntities();
            IQueryable<TINHTRANG> custQuery = devicemanager.TINHTRANGs.AsQueryable<TINHTRANG>();
            return custQuery.ToList();
        }

        public bool DeleteRecord(TINHTRANG record)
        {
            throw new NotImplementedException();
        }
    }
}
